//
//  GHSSHViewController.m
//  penzer
//
//  Created by 还带大道 on 2018/11/15.
//  Copyright © 2018年 caiyc. All rights reserved.
//

#import "GHSSHViewController.h"
#import "GHSOrderTableViewCell.h"
#import "GHSOD_THViewController.h"
#import "GHSOD_HHViewController.h"

@interface GHSSHViewController ()<UITableViewDataSource,UITableViewDelegate>
@property (nonatomic,weak) UITableView *tableView;
@end

@implementation GHSSHViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setupTableView];
}


- (void)setupTableView
{
    UITableView *tableView = [UITableView new];
    _tableView =tableView;
    tableView.delegate = self;
    tableView.dataSource = self;
    tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    tableView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:tableView];
    
    [tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.bottom.equalTo(self.view);
    }];
    
    [self.tableView registerNib:[UINib nibWithNibName:NSStringFromClass([GHSOrderTableViewCell class]) bundle:nil]  forCellReuseIdentifier:NSStringFromClass([GHSOrderTableViewCell class])];
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 5;
}


- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 185;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    GHSOrderTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([GHSOrderTableViewCell class])];
    if(indexPath.row %2 ==0){
        cell.type = GHSOrderType_HH;
    }else{
        cell.type = GHSOrderType_TH;
    }
    
    cell.handleBtnBlock = ^(GHSOrderType type) {
        [self go_shWithType:type];
    };
    return cell;
}

- (void)go_shWithType:(GHSOrderType)type
{
    if(type == GHSOrderType_HH){
        GHSOD_HHViewController *hh = [GHSOD_HHViewController new];
        [self.navigationController pushViewController:hh animated:YES];
    }else{
        GHSOD_THViewController *th = [GHSOD_THViewController new];
        [self.navigationController pushViewController:th animated:YES];
    }
}
@end
